import request from '@/utils/request'

/**
 * 服务商申请
 * /admin/m/serviceProvider
 * method: POST
 */
export const applyServiceProviderAPI = (data: any) => {
  return request.post({
    url: '/admin/m/serviceProvider',
    data
  })
}
/**
 * 服务商详情
 * params {id , uid}
 * admin/m/serviceProvider/detail/{id}
 */

export const getServiceProviderDetailAPI = (data): Pms<IServiceProviderDetail> => {
  return request.get({
    url: `/admin/m/serviceProvider/detail`,
    data
  })
}

/**
 * 服务商列表
 */
export const getServiceProviderListAPI = (data: any): PmsPage<IServcieProviderListItem> => {
  return request.get({
    url: '/admin/m/serviceProvider/page',
    data
  })
}

/**
 * /admin/m/cacUser/page
 */

export const getCacUserAPI = (data: any): PmsPage<ICacUser> => {
  return request.get({
    url: '/admin/m/cacUser/page',
    data
  })
}

/**
 * 切换角色
 */

export const switchRoleAPI = (id: string | number): Pms<any> => {
  return request.put({
    url: '/admin/appuser/choose-user-role?roleId=' + id
  })
}

/**
 * 绑定服务商
 * /admin/appuser/bind/{spId}
 */
export const bindServiceProviderAPI = (id: string, inviteSource = '3') => {
  return request.put({
    url: '/admin/appuser/bind/' + id + '?inviteSource=' + inviteSource
  })
}

/**
 * 我的客户
 */

export const getMyCustomerAPI = (data: any): PmsPage<IMycustorme> => {
  return request.get({
    url: '/admin/appuser/page',
    data
  })
}

/**
 * 通过uid获取服务商详情
 */
export const getServiceProviderDetailByUidAPI = (uid: string): Pms<IServiceProviderDetail> => {
  return request.get({
    url: '/admin/m/serviceProvider/detailByUid/' + uid
  })
}

/**
 * 编辑服务商
 */
export const editServiceProviderAPI = (data: any) => {
  return request.put({
    url: '/admin/m/serviceProvider',
    data
  })
}

/**
 * 服务商检查
 */
export const checkServiceProviderAPI = (data: any) => {
  return request.get({
    url: '/admin/m/serviceProvider/check'
  })
}
